package com.cyz.springdemo.config;

import com.cyz.springdemo.filter.HelloFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @program: springdemo
 * @description: 注册拦截器为bean
 * @author: wangjie
 * @create: 2019-07-25 17:12
 **/
//@Configuration
public class FilterConfig {


    /**
     * 将HelloFilter拦截器注册成bean
     * @return
     */
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        HelloFilter helloFilter = new HelloFilter();
        bean.setFilter(helloFilter);
        //拦截所有的路径
        bean.addUrlPatterns("/hello/index");

        return bean;
    }
}
